import java.util.List;

import es.deusto.ingenieria.is.csp.formulation.Constraint;
import es.deusto.ingenieria.is.csp.formulation.Variable;


public class ColorConstraint extends Constraint<Gem>{

	public ColorConstraint(String name, List<Variable<Gem>> variables) {
		super(name, variables);
	}

	@Override
	public boolean isSatisfied(Variable<Gem> variable, Gem value) {
		Board board = BoardSingletone.getInstance().getBoard();
		CellList section = board.sectionContains(variable);
		List<Cell> cells = section.getCells();
		for (Variable<Gem> varAux : cells){
			if(varAux.getValue().getColor().equals(value.getColor())){
				return false;
			}
		}
		return true;
	}

}
